<?php 
/**
 * 战报
 */
class App_battlefie{
	static public function getList($pageCount){
		$Db = loadDB();
		
		$result = $Db->getAll("SELECT * FROM `sysmsg` WHERE `subtype`=1001 OR `subtype`=1005 OR `subtype`=1006 ORDER BY `time` DESC LIMIT 0 , {$pageCount}");
		
		foreach($result as $k => $row) {
			if(!empty($row['data'])) {
				$result[$k]['data'] = unserialize($row['data']);
			}
		}
		
		return $result;
	}
	static public function getBattlefie(){
		loadLib('User');
		//战报信息
		$gains_list=self::getList(10);
		
		$uin_gains = array();
		foreach($gains_list as $row) {
			$uin_gains[] = $row['uin'];
			$uin_gain[] = $row['data']['send_uin'];
		}
		//战报姓名
		$info=User::getBaseInfo($uin_gains);
		$infos=User::getBaseInfo($uin_gain);
		foreach($gains_list as $k => $row) {
			$gains_list[$k]['uin_name'] = isset($info[$row['uin']]) ? $info[$row['uin']]['name'] : '';
			$gains_list[$k]['uin_sex'] = isset($info[$row['uin']]) ? $info[$row['uin']]['sex'] : '';
			$gains_list[$k]['name'] = isset($infos[$row['data']['send_uin']]) ? $infos[$row['data']['send_uin']]['name'] : '';
			$gains_list[$k]['sex'] = isset($infos[$row['data']['send_uin']]) ? $infos[$row['data']['send_uin']]['sex'] : '';
		}
		//print_r($gains_list);
		return $gains_list;
		
	}
}
# end of script